package com.ailanyin.admin.service.impl;

import com.ailanyin.admin.service.CommonFileService;
import com.ailanyin.common.utils.FileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * @author ailanyin
 * @version 1.0
 * @since 2021/11/4 0004 下午 16:04
 */
@Service
public class CommonFileServiceImpl implements CommonFileService {

    @Autowired
    private HttpServletRequest request;

    @Value("${upload.path}")
    private String path;
    /**
     * 文件上传
     *
     * @param file file
     * @return url
     */
    @Override
    public String fileUpload(MultipartFile file) {

        return FileUtil.upload(file,request,path);
    }
}
